﻿using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Collections.Generic;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Text;
using BussinessLib;
using Entity;

/// <summary>
/// OrderList 的摘要说明
/// </summary>
[WebService(Namespace = "http://NCI5.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class OrderList : System.Web.Services.WebService {

    public OrderList () {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }

    [WebMethod]
    public String listOrderInfo(string username,bool isOrderIdOnly)
    {
        
        Helper hp = new Helper();

        StringBuilder result = new StringBuilder();

        if(username.Length ==0)
        {
            using (IDataReader reader = hp.ExecuteDataReader("select * from OrderRecord" ))
        {
            while (reader.Read())
            {

                result.Append(reader[0].ToString());
                if (isOrderIdOnly)
                {
                    result.Append(";");
                    continue;
                }
                result.Append(",");

                result.Append(reader[1].ToString());
                result.Append(",");
                //result.Append(reader[2].ToString());
                //result.Append(",");
                result.Append(reader[3]);
                result.Append(",");
                result.Append(reader[4].ToString());
                result.Append(",");
                result.Append(reader[5].ToString());
                result.Append(",");
                result.Append(reader[6].ToString());
                result.Append(",");
                result.Append(reader[7].ToString());
                result.Append(";");



            }
        }
        }
        else
        {
        using (IDataReader reader = hp.ExecuteDataReader("select * from OrderRecord where ord_nUserID=" + username))
        {
            while (reader.Read())
            {
                
                result.Append(reader[0].ToString());
                if (isOrderIdOnly)
                {
                    result.Append(";");
                    continue;
                }
                result.Append(",");
              
                result.Append(reader[1].ToString());
                result.Append(",");
                //result.Append(reader[2].ToString());
                //result.Append(",");
                result.Append(reader[3]);
                result.Append(",");
                result.Append(reader[4].ToString());
                result.Append(",");
                result.Append(reader[5].ToString());
                result.Append(",");
                result.Append(reader[6].ToString());
                result.Append(",");
                result.Append(reader[7].ToString());
                result.Append(";");
                

               
            }
        }
        }
        return result.ToString();
    }
  
    
}

